import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/views/layout/Layout'
import RouteLayout from '@/views/layout/RouteLayout'
/* Router Modules */
// import componentsRouter from './modules/components'
// import chartsRouter from './modules/charts'
// import tableRouter from './modules/table'
// import nestedRouter from './modules/nested'

/** note: Submenu only appear when children.length>=1
 *  detail see  https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 **/
export const constantRouterMap = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/404',
    component: () => import('@/views/errorPage/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/errorPage/401'),
    hidden: true
  },
  {
    path: '/announcement',
    component: Layout,
    meta: {
      title: '系统公告',
      icon: 'component'
    },
    children: [
      {
        path: '/announcement',
        component: () => import('@/views/announcement/index'),
        name: 'announcement',
        meta: { title: 'announcement', icon: 'dashboard', noCache: true }
      }
    ],
    hidden: true
  },
  {
    path: '/worklist',
    component: Layout,
    meta: {
      title: 'worklist',
      icon: 'component'
    },
    children: [
      {
        path: 'myWorkList',
        component: () => import('@/views/worklist/myWorkList'),
        name: 'myWorkList',
        meta: { title: 'myWorkList', icon: 'tab', noCache: true }
      },
      {
        path: 'submitWorkList',
        component: () => import('@/views/worklist/submitWorkList'),
        name: 'submitWorkList',
        meta: { title: 'submitWorkList', icon: 'documentation', noCache: true }
      },
      {
        path: 'workListDetails/:id',
        component: () => import('@/views/worklist/workListDetails'),
        name: 'workListDetails',
        meta: { title: 'workListDetails', icon: 'documentation', noCache: true, hidden: true },
        hidden: true
      }
    ]
  },
  {
    path: '/build',
    component: Layout,
    meta: {
      title: 'build',
      icon: 'component'
    },
    children: [
      // {
      //   path: 'yibiaopan',
      //   component: () => import('@/views/worklist/submitWorkList'),
      //   name: 'yibiaopan',
      //   meta: { title: '仪表盘', icon: 'documentation', noCache: true }
      // },
      {
        path: 'selfhelp',
        meta: {
          title: '自助发布',
          icon: 'component'
        },
        component: RouteLayout,
        children: [
          {
            path: 'deploylist',
            name: 'deploylist',
            component: () => import('@/views/selfhelp/deploylist'),
            meta: { title: '应用部署', icon: 'documentation', noCache: true }
          },
          {
            path: 'deploypage',
            name: 'deploypage',
            hidden: true,
            component: () => import('@/views/selfhelp/deploypage'),
            meta: { title: '部署页面', icon: 'documentation', noCache: true }
          },
          {
            path: 'deployrecord',
            name: 'deployrecord',
            component: () => import('@/views/selfhelp/deployrecord'),
            meta: { title: '部署记录', icon: 'documentation', noCache: true }
          }
        ]
      },
      {
        path: '/config',
        component: () => import('@/views/build/redirect'),
        meta: {
          title: 'config',
          icon: 'component'
        },
        children: [
          {
            path: 'app',
            component: () => import('@/views/build/config/app'),
            name: 'app',
            meta: { title: '基础应用管理', icon: 'documentation', noCache: true }
          },
          {
            path: 'env',
            component: () => import('@/views/build/config/env'),
            name: 'env',
            meta: { title: '环境管理', icon: 'documentation', noCache: true }
          },
          {
            path: 'deploy',
            component: () => import('@/views/build/config/deployengine'),
            name: 'deploy',
            meta: { title: '发布引擎管理', icon: 'documentation', noCache: true }
          },
          {
            path: 'apply_list',
            name: 'apply_list',
            component: () => import('@/views/apply_cutin/apply_list'),
            meta: { title: '应用部署管理', icon: 'documentation', noCache: true }
          },
          {
            path: 'springboot',
            name: 'springboot',
            component: () => import('@/views/apply_cutin/springboot'),
            hidden: true,
            meta: { title: 'SPRINGBOOT', icon: 'documentation', noCache: true }
          },
          {
            path: 'staticnode',
            name: 'staticnode',
            component: () => import('@/views/apply_cutin/staticnode'),
            hidden: true,
            meta: { title: 'STATIC_NODE', icon: 'documentation', noCache: true }
          }
        ]
      },
      {
        path: 'workListDetails/:id',
        component: () => import('@/views/worklist/workListDetails'),
        name: 'workListDetails',
        meta: { title: 'workListDetails', icon: 'documentation', noCache: true, hidden: true },
        hidden: true
      }
    ]
  }
]

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  { path: '*', redirect: '/404', hidden: true }
]

